import 'dart:core';
import 'package:dk_flutter_base/dk_ui.dart';
import 'package:dk_flutter_module_sale/sale/sale_in/following_record/bean/record_config_bean.dart';
import 'package:flutter/material.dart';
import 'record_field_widget.dart';

typedef SingleChoiceCallback = void Function();

// ignore: must_be_immutable
class RecordPriceWidget extends StatelessWidget {
  final SingleChoiceCallback singleChoiceCallback;
  final String content;
  final ConfigBean configBean;
  final TextEditingController priceEditingController;
  final FocusNode _nodePrice = FocusNode();

  RecordPriceWidget(
      {this.configBean,
      this.content,
      this.singleChoiceCallback,
      this.priceEditingController});
  @override
  Widget build(BuildContext context) {
    return buildRecordSelectTimeWidget(context);
  }

  Widget buildRecordSelectTimeWidget(BuildContext context) {
    return Container(
        color: Colors.white,
        child: InkWell(
          child: Column(
            children: <Widget>[
              Container(
                height: 48,
                padding: EdgeInsets.only(left: 16, right: 16),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      configBean.title,
                      style: TextStyle(
                          color: Color(0xff666666),
                          fontSize: 14,
                          fontWeight: FontWeight.normal),
                    ),
                    Spacer(),
                    Expanded(
                      child: RecordFieldWidget(
                        focusNode: _nodePrice,
                        placeHolder: configBean.placeholder,
                        controller: priceEditingController,
                        //keyboardType: TextInputType.number,
                      ),
                    ),
                    SizedBox(width: 2,),
                    Text(
                      configBean.unit,
                      textAlign: TextAlign.right,
                      style: TextStyle(
                          color: Color(0xff333333),
                          fontSize: 14,
                          fontWeight: FontWeight.normal),
                    ),
                  ],
                ),
              ),
              Container(
                height: 10,
                color: Color(0xffF7F8F9),
              ),
            ],
          ),
          onTap: () {
            if (singleChoiceCallback != null) {
              singleChoiceCallback();
            }
          },
        ));
  }
}
